package com.miracle9.game.thread;

import com.miracle9.game.bean.GameStatus;
import com.miracle9.game.bean.UserGameTypeSession;
import com.miracle9.game.dao.UserServiceDao;
import com.miracle9.game.entity.*;
import com.miracle9.game.server.message.AmfMessageSend;
import com.miracle9.game.server.message.*;
import com.miracle9.game.service.*;
import com.miracle9.game.util.GameParameterAssist;
import com.miracle9.game.util.MyUtil;
import com.miracle9.game.util.SessionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.mina.core.session.IoSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Service("myThread")
public class MyThread extends Thread {

    private Logger logger;
    @Autowired
    private UserShutupService userShutupService;
    @Autowired
    private UserService userService;
    @Autowired
    private UserServiceDao userServiceDao;
    @Autowired
    private SystemConfigService systemConfigService;
    @Autowired
    private PayApplyService payApplyService;
    @Autowired
    private PromoterService promoterService;
    @Autowired
    private PromoterAppService promoterAppService;
    @Autowired
    private ActivityService activityService;
    @Autowired
    private DeskService deskService;
    private int count;

    public MyThread() {
        this.logger = Logger.getLogger(MyThread.class);
        this.count = 0;
    }

    @PostConstruct
    public void myThreadStart() {
        start();
    }

    public void run() {
        for (; ; ) {
            try {
                gameNotifyMessageProcess();
                gameNotifyMessageSend();
                ioSessionRemove();
                payApplyRemove();
                checkWarning();
                autoAddGold();
                Thread.sleep(10000L);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private void gameNotifyMessageProcess() {
        try {
            List<UserShutup> shutups = this.userShutupService.getAllUserShutup();
            for (UserShutup u : shutups) {
                if (System.currentTimeMillis() >= u.getDeleteDatetime()) {
                    this.userShutupService.deleteUserShutup(u.getUserId());
                    this.userService.updateShutupStatus(u.getUserId(), 0);
                    if (GameParameterAssist.bh.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : LuckSocketHandler.A) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.bi.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : FishSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.fishKingBi.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : FishKingSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.likuiFishUserId.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : LiKuiFishSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.goldenFishUserId.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : GoldenCicadaFishSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.tgUserId.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : TianGongSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.goldSharkUserId.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : GoldSharkSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.lhdUserId.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : DragonTigerSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.bcbmUserId.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : BcbmSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.bj.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : CardSocketHandler.w) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.bk.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : BulletSocketHandler.v) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.bl.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : MermaidSocketHandler.B) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.aN.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : LackSocketHandler.z) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.aP.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : com.miracle9.game.server.message.JoySocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.bs.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : WaterSocketHandler.F) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                    if (GameParameterAssist.thousandFishGametypeMap.containsKey(Integer.valueOf(u.getUserId()))) {
                        for (IoSession s : ThousandFishSocketHandler.x) {
                            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/userShutup", new Object[]{Integer.valueOf(u.getUserId()), Boolean.valueOf(false)}));
                        }
                    }
                }
            }
        } catch (Exception e) {
            this.logger.error("", e);
        }
    }

    private void gameNotifyMessageSend() {
        this.count += 1;
        try {
            SystemConfig config = this.systemConfigService.getSystemConfig();
            if ((config.getOperationStatus() == 1) && (System.currentTimeMillis() > config.getOperationStopDate())) {
                config.setOperationStatus(0);
                config.setGameStatus(1);
                config.setWeihuTime(-1);
                config.setContent("");
                this.systemConfigService.updateWeihuStatus(config);
                this.systemConfigService.pubNotice();
                GameStatus gs = new GameStatus();
                gs.statusIndex = 1;
                gs.content = "";
                gs.cooperateMode = config.getOperationStatus();
                gs.cooperateStartDate = "——————";
                gs.cooperateEndDate = "——————";
                for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncGameStatus", new Object[]{gs}));
                }
                this.count = 0;
                return;
            }
            if (config.getWeihuTime() != -1) {
                Calendar calendar = Calendar.getInstance();
                int hour = calendar.get(11);
                SimpleDateFormat sdf;
                if (hour == config.getWeihuTime()) {
                    config.setGameStatus(1);
                    config.setWeihuTime(-1);
                    config.setContent("");
                    this.systemConfigService.updateWeihuStatus(config);
                    this.systemConfigService.pubNotice();
                    GameStatus gs2 = new GameStatus();
                    gs2.statusIndex = 1;
                    gs2.content = "";
                    gs2.cooperateMode = config.getOperationStatus();
                    gs2.cooperateStartDate = "——————";
                    gs2.cooperateEndDate = "——————";
                    if (config.getOperationStatus() == 1) {
                        gs2.cooperateStartDate = config.getOperationDate();
                        Calendar c = Calendar.getInstance();
                        sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                        c.setTimeInMillis(config.getOperationStopDate());
                        gs2.cooperateEndDate = sdf.format(c.getTime());
                    }
                    for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
                        AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncGameStatus", new Object[]{gs2}));
                    }
                    this.count = 0;
                } else if (hour + 1 == config.getWeihuTime()) {
                    int minute = calendar.get(Calendar.MINUTE);
                    if ((minute >= 45) && (this.count % 6 == 0)) {
                        //大厅
                        Map<String, Object> result = new HashMap<>();
                        result.put("content", config.getContent());
                        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.ba.entrySet()) {
                            MessageSend.q.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "scrollMessage", new Object[]{result}));
                        }
                        //子游戏
                        List<UserGameTypeSession> userGameSessionList = SessionUtils.getUserGameSession();
                        for (UserGameTypeSession userGameTypeSession : userGameSessionList) {
                            for (Map.Entry<Integer, Integer> entry : userGameTypeSession.getUserGameTypeMap().entrySet()) {
                                for (IoSession session : userGameTypeSession.getSessionSet()) {
                                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(session, "manageService/sendNotice", new Object[]{entry.getKey(), config.getContent()}));
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            this.logger.error("", e);
        }
    }

    private void ioSessionRemove() {
        try {
            for (Map.Entry<IoSession, Map<Integer, Long>> entry : GameParameterAssist.bw.entrySet()) {
                for (Map.Entry<Integer, Long> longEntry : entry.getValue().entrySet()) {
                    if (System.currentTimeMillis() >= longEntry.getValue()) {
                        GameParameterAssist.bw.remove(entry.getKey());
                    }
                }
            }
            for (Map.Entry<IoSession, Map<Integer, Long>> entry : GameParameterAssist.bz.entrySet()) {
                for (Map.Entry<Integer, Long> longEntry : entry.getValue().entrySet()) {
                    if (System.currentTimeMillis() >= longEntry.getValue()) {
                        GameParameterAssist.bz.remove(entry.getKey());
                        GameParameterAssist.bB.remove(longEntry.getKey());
                    }
                }
            }
        } catch (Exception e) {
            this.logger.error("", e);
        }
    }

    private void payApplyRemove() {
        try {
            synchronized (PayApplyService.expiryLock) {
                List<PayApply> us = this.payApplyService.getAllPayApply();
                Iterator<PayApply> it = us.iterator();
                while (it.hasNext()) {
                    PayApply u = it.next();
                    if (System.currentTimeMillis() > u.getTimeout()) {
                        boolean updateSuccess = this.payApplyService.updateStatus(u.getId(), PayApply.PayApplyState.WAIVE);
                        if (u.getUserType() == 0) {
                            IoSession session = GameParameterAssist.ba.get(u.getUserId());
                            if ((updateSuccess) && (u.getType() == 0)) {
                                this.userService.updatePayMoney(u.getUserId(), 0);
                                if (session != null) {
                                    this.payApplyService.updateNotice(u.getId(), true);
                                    UserService.recharge(session);
                                }
                            } else if ((updateSuccess) && (u.getType() == 1)) {
                                this.userService.addGameGold(u.getUserId(), u.getAmmount());
                                this.userService.updateExpiryNum(u.getUserId(), 0);
                                User user = this.userService.getUser(u.getUserId());
                                UserService.pubGoldNotice(user);
                                if (session != null) {
                                    this.payApplyService.updateNotice(u.getId(), true);
                                    UserService.excharge(session);
                                }
                            }
                            User user = this.userService.getUser(u.getUserId());
                            if (user.getPromoterId() == 0) {
                                Map<String, Object> countMap = this.userService.getUserPayCount();
                                for (IoSession as : GameParameterAssist.be.values()) {
                                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(as, "userPayCount", new Object[]{countMap}));
                                }
                            } else {
                                IoSession s = GameParameterAssist.bx.get(user.getPromoterId());
                                if (s != null) {
                                    this.promoterAppService.promoterAppUserPayCount(s, user.getPromoterId());
                                }
                            }
                        } else {
                            Promoter promoter = this.promoterService.getPromoter(u.getUserId());
                            if ((updateSuccess) && (u.getType() == 0)) {
                                this.promoterService.updatePayMoney(u.getUserId(), 0);
                                IoSession s2 = GameParameterAssist.bx.get(promoter.getId());
                                if (s2 != null) {
                                    this.payApplyService.updateNotice(u.getId(), true);
                                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "syncPayResult", new Object[]{MyUtil.getSessionAttribute(s2, "payAutoTimeoutTip")}));
                                }
                            } else if ((updateSuccess) && (u.getType() == 1)) {
                                this.promoterService.addGold(u.getUserId(), u.getAmmount());
                                this.promoterService.updateExpiryNum(u.getUserId(), 0);
                                IoSession s2 = GameParameterAssist.bx.get(promoter.getId());
                                if (s2 != null) {
                                    this.payApplyService.updateNotice(u.getId(), true);
                                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "syncExpiryResult", new Object[]{MyUtil.getSessionAttribute(s2, "expiryAutoTimeoutTip")}));
                                }
                            }
                            if (promoter.getParentId() == 0) {
                                Map<String, Object> countMap2 = this.promoterService.getPromoterPayCount();
                                for (IoSession as2 : GameParameterAssist.be.values()) {
                                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(as2, "promoterPayCount", new Object[]{countMap2}));
                                }
                            } else {
                                IoSession s2 = GameParameterAssist.bx.get(promoter.getParentId());
                                if (s2 != null) {
                                    this.promoterAppService.promoterAppPayCount(s2, promoter.getParentId());
                                }
                            }
                        }
                        it.remove();
                    }
                }
            }
        } catch (Exception e) {
            this.logger.error("", e);
        }
    }

    public void activity() {
        ActivityInfo activityInfo = this.activityService.getActivityInfo();
        if (activityInfo == null) {
            return;
        }
        Iterator localIterator3;
        if (activityInfo.getActivityStatus() == 1) {
            Calendar calendar = Calendar.getInstance();
            int hour = calendar.get(Calendar.HOUR_OF_DAY);
            int minute = calendar.get(12);
            int nBonusRainTime = 0;
            List<Activity> activityList = this.activityService.getActivityList(6);
            for (Activity activity : activityList) {
                nBonusRainTime = activity.getCondition1();
                if (hour + 1 == nBonusRainTime) {
                    minute = calendar.get(12);
                    if (minute >= 50) {
                        if (this.count % 6 == 0) {
                            String strContent = "万元红包来袭活动将在" + (60 - minute) + "分钟后开始";
                            for (Integer uid : GameParameterAssist.aR.keySet()) {
                                IoSession s = GameParameterAssist.aR.get(uid);
                                MessageSend.q.notifyAllOperating(new StorageMethodEntity(s, "scrollMessage", new Object[]{strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aS.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = LuckSocketHandler.A.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aT.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = FishSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aT_king.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = FishKingSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aU.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = CardSocketHandler.w.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aV.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = BulletSocketHandler.v.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aW.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = MermaidSocketHandler.B.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aX.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = LackSocketHandler.z.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aY.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = com.miracle9.game.server.message.JoySocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aZ.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = WaterSocketHandler.F.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.thounsandFishGameType2.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = ThousandFishSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aT_likui.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = LiKuiFishSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aT_golden.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = GoldenCicadaFishSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aT_tg.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = TianGongSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aT_bcbm.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = BcbmSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aT_goldShark.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = GoldSharkSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                            for (activityList = (List<Activity>) GameParameterAssist.aT_lhd.keySet().iterator(); ((Iterator) activityList).hasNext(); localIterator3.hasNext()) {
                                Integer uid = (Integer) ((Iterator) activityList).next();
                                localIterator3 = DragonTigerSocketHandler.x.iterator();
                                //continue;
                                IoSession s = (IoSession) localIterator3.next();
                                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/sendNotice", new Object[]{uid, strContent}));
                            }
                        }
                    }
                }
            }
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String strStartDate = activityInfo.getStartDate();
        String strEndDate = activityInfo.getEndDate();
        Map map = new HashMap();
        try {
            Date startDate = sdf.parse(strStartDate);
            Date endDate = sdf.parse(strEndDate);
            long startTime = startDate.getTime();
            long endTime = endDate.getTime();
            if (((activityInfo.getActivityStatus() == 0) || (activityInfo.getActivityStatus() == 2)) && (System.currentTimeMillis() >= startTime) && (System.currentTimeMillis() < endTime)) {
                this.activityService.updateActivityStatus(1);
                activityInfo.setActivityStatus(1);
                map.put("activityInfo", activityInfo);
                for (Map.Entry entry : GameParameterAssist.be.entrySet()) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity((IoSession) entry.getValue(), "getActivityInfo", new Object[]{map}));
                }
                this.activityService.updateActivityInfoNotice();
                Activity activity2 = new Activity();
                this.activityService.pubUpdateActivityNotice(activity2);
                Object users = this.userService.getActivityUserList();
        /*for (User user : (List)users)
        {
          int nLevel = user.getLevel();
          this.lIlIIllIlIllllIIl.updateLevelCondition2(nLevel, user.getId(), 3);
        }*/
                for (int i = 0; i < ((List) users).size(); i++) {
                    int nLevel = ((User) ((List) users).get(i)).getLevel();
                    this.activityService.updateLevelCondition2(nLevel, ((User) ((List) users).get(i)).getId(), 3);
                }
                try {
                    Thread.sleep(60000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if ((activityInfo.getActivityStatus() == 1) && (System.currentTimeMillis() > endTime)) {
                List allActivityList = this.activityService.getActivityList();
                if (allActivityList.size() == 0) {
                    this.activityService.updateActivityStatus(0);
                    activityInfo.setActivityStatus(0);
                } else if (allActivityList.size() != 0) {
                    this.activityService.updateActivityStatus(2);
                    activityInfo.setActivityStatus(2);
                }
                map.put("activityInfo", activityInfo);
                for (Map.Entry entry2 : GameParameterAssist.be.entrySet()) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity((IoSession) entry2.getValue(), "getActivityInfo", new Object[]{map}));
                }
                this.activityService.updateActivityInfoNotice();
                Activity activity3 = new Activity();
                this.activityService.pubUpdateActivityNotice(activity3);
                this.activityService.updateUserActivityStatus(0);
                this.activityService.cleanSumYa();
            }
        } catch (ParseException e2) {
            e2.printStackTrace();
        }
    }

    public void checkWarning() {
        Calendar calendar = Calendar.getInstance();
        int minute = calendar.get(12);
        if ((minute == 0) || (minute == 30)) {
            List<UserWarning> userWarnings = new ArrayList();
            userWarnings = this.userService.getUserWarning();
            for (UserWarning userWarning : userWarnings) {
                this.userService.checkWarning(userWarning.getUserId());
            }
            try {
                Thread.sleep(60000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public void getJoyPrivateDeskParameter() {
        this.deskService.getJoyPrivateDeskParameter();
    }

    public void autoAddGold(){
        SystemConfig systemConfig = this.systemConfigService.getSystemConfig();
        //机器人代理充值游戏币
        if (systemConfig!=null && StringUtils.isNotBlank(systemConfig.getRobotPromoter()) && systemConfig.getRobotAutoGold()==1 && systemConfig.getRobotGold() > 0) {
            List<User> list = userService.getNeedAddGoldRobotUserList(systemConfig.getRobotPromoter());
            for (User user : list) {
                userService.pay(user.getId(), systemConfig.getRobotGold(), 0, null);
            }
        }
    }

}
